//
//  GuideTextView.m
//  ;
//
//  Created by yinqy on 15/1/26.
//  Copyright (c) 2015年 北京娇羞科技有限公司. All rights reserved.
//

#import "GuideTextView.h"

#define TITLE_FONT_SIZE [DimensUtils getScaleY:15]
#define SUBTITLE_FONT_SIZE [DimensUtils getScaleY:12]


@interface GuideTextView()
{
    UILabel *_titleLabel;
    UILabel *_subTitleLabel;
}

@end
@implementation GuideTextView


- (instancetype)initWithTitle:(NSString *)title subTitle:(NSString *)subTitle type:(GuideTextViewType)type{
    self = [super init];
    if (self) {
        _titleLabel = [[UILabel alloc]init];
        [_titleLabel setFont:[UIFont systemFontOfSize:TITLE_FONT_SIZE]];
        [_titleLabel setTextColor:JXColor(102, 102, 102)];
        CGSize titleSize = [title sizeWithFont:_titleLabel.font];
        [_titleLabel setFrame:CGRectMake(0, 0, titleSize.width, titleSize.height)];
        [_titleLabel setText:title];
        [self addSubview:_titleLabel];
        
        
        _subTitleLabel = [[UILabel alloc]init];
        [_subTitleLabel setFont:[UIFont systemFontOfSize:SUBTITLE_FONT_SIZE]];
        CGSize subTitleSize = [subTitle sizeWithFont:_subTitleLabel.font];
        [_subTitleLabel setFrame:CGRectMake(0, CGRectGetMaxY(_titleLabel.frame)+JXPublicInset/2, _titleLabel.width, subTitleSize.height)];
        [_subTitleLabel setTextColor:JXColor(153, 153, 153)];
        [_subTitleLabel setText:subTitle];
        [self addSubview:_subTitleLabel];
        if (type==GuideTextViewTypeLeft) {
            [_subTitleLabel setTextAlignment:NSTextAlignmentRight];
        }else{
            [_subTitleLabel setTextAlignment:NSTextAlignmentLeft];
        }
        [self setSize:CGSizeMake(_titleLabel.width, CGRectGetMaxY(_subTitleLabel.frame))];
    }
    return self;
}

@end
